package midoo.server.core;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;

/**
 * Created by ajianzheng on 2015/4/10.
 *
 */
public class MChannelReadHandler extends ChannelInboundHandlerAdapter {
//    private static final Logger LOGGER = LoggerFactory.getLogger(KChannelReadHandler.class);

    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        MChannelStatistics.getInstance().newRequest();

        MMessageExecutor.getInstance().exec(ctx, msg);
    }

//    @Override
//    public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
//        super.userEventTriggered(ctx, evt);
//
//        if (evt instanceof IdleStateEvent) {
//            IdleStateEvent idleStateEvent = (IdleStateEvent) evt;
//
//            if (idleStateEvent.state() == IdleState.ALL_IDLE) {
//                ByteBuf buf = ctx.alloc().ioBuffer();
//                buf.writeBytes("\r\n\r\n".getBytes());
//                ctx.writeAndFlush(buf);
//            }
//        }
//    }
}
